#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Author:    御风
# @Mail:      zhong.yufeng@foxmail.com
# @Time:      2022/4/10 18:43


from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm.attributes import InstrumentedAttribute

Base = declarative_base()


def getModuleColumns(moduleClass):
    result = { }
    for attrName in dir(moduleClass):
        if attrName.startswith("__") or attrName.endswith("__"):
            continue
        attr = getattr(moduleClass, attrName, None)
        if not isinstance(attr, InstrumentedAttribute):
            continue
        result[attrName] = attr.type
    return result
